<template>
	<!--外部请用 :slotted(.类名) 修改样式-->
  <button open-type="getPhoneNumber" lang="zh_CN" @getphonenumber="onGetphonenumber" :class="clazz">
	<slot></slot>
  </button>
</template>

<script setup>
	const props = defineProps({
	  clazz: String,
	  callback: Function
	})
	
	function onGetphonenumber(e){
		let ret = e.detail;
		if(ret.errMsg != "getPhoneNumber:ok"){
			throw new Error('获取手机号失败！');
			
		}
		
		uni.showToast({
			title:"授权成功",
			success(){
				getApp().globalData.user.isLogin = true;
				
				props.callback && setTimeout(props.callback, 1500)
			}
		})
	}

</script>

<style>
	
</style>